﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CNKI.Graduate.Framework.Db
{
    public interface IDatabase
    {
        string GetSqlParamVar(string name);
        DataTable ExecuteDataTable(string commandText);

        DataTable ExecuteDataTable(string commandText, SqlParamsData[] sqlParams);

        IDataReader ExecuteReader(string commandText);

        IDataReader ExecuteReader(string commandText, SqlParamsData[] sqlParams);

        object ExecuteScalar(string commandText);

        object ExecuteScalar(string commandText, SqlParamsData[] sqlParams);

        /// <summary>
        /// <para>执行非查询的DML语句<paramref name="commandText"/>.</para>
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        int ExecuteNonQuery(string commandText);

        /// <summary>
        /// <para>执行非查询的DML语句<paramref name="commandText"/>.</para>
        /// </summary>
        /// <param name="commandText"></param>
        /// <param name="sqlParams">sql参数</param>
        /// <returns></returns>
        int ExecuteNonQuery(string commandText, SqlParamsData[] sqlParams);

        /// <summary>
        /// 执行多条sql语句
        /// </summary>
        /// <param name="sqlPair"></param>
        /// <returns></returns>
        bool ExecuteMutiNonQuery(IDictionary<string, SqlParamsData[]> sqlPair);

        bool ExecuteMutiNonQuery(string[] sqlList);


        /// <summary>
        /// 将dataTable存入与其同结构的表中
        /// </summary>
        /// <param name="dataTable"></param>
        /// <returns></returns>
        bool SaveDataTableContent(DataTable dataTable);
        /// <summary>
        /// 将dataTable存入与其同结构的表中
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="tableName"></param>
        /// <returns></returns>
        bool SaveDataTableContent(DataTable dataTable, string tableName);
        /// <summary>
        /// 更新dataTable表结构
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="primaryKeyColumns">主键列</param>
        /// <returns></returns>
        bool UpdateDataTableContent(DataTable dataTable, string[] primaryKeyColumns);
        /// <summary>
        /// 更新dataTable表
        /// </summary>
        /// <param name="dataTable"></param>
        /// <param name="tableName"></param>
        /// <param name="primaryKeyColumns">主键列</param>
        /// <returns></returns>
        bool UpdateDataTableContent(DataTable dataTable, string tableName, string[] primaryKeyColumns);


    }
}
